//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_fillbackpacks.sqf"
#include "x_setup.sqf"

#include "x_uiinc.sqf"

private ["_control", "_bar", "_control2", "_pic"];
disableSerialization;
_control = __uiGetVar(GVAR(BACKPACK_DIALOG)) displayCtrl 1000;
lbClear _control;

_bar = switch (GVAR(side_player)) do {
	case blufor: {GVAR(backpackclasses) select 0};
	case opfor: {GVAR(backpackclasses) select 1};
};

{_control lbAdd getText (configFile/"cfgVehicles"/_x/"displayName")} forEach _bar;

_control lbSetCurSel 0;

_control = __uiGetVar(GVAR(BACKPACK_DIALOG)) displayCtrl 1002;
_control2 = __uiGetVar(GVAR(BACKPACK_DIALOG)) displayCtrl 1004;

if (!isNull (unitBackpack player)) then {
	_pic = getText (configFile/"cfgVehicles"/typeOf (unitBackpack player)/"picture");

	_control ctrlSetText _pic;
	_control2 ctrlSetText format [(localize "STR_DOM_MISSIONSTRING_692"), getText (configFile/"cfgVehicles"/typeOf (unitBackpack player)/"displayName")];
} else {
	_control ctrlSetText "";
	_control2 ctrlSetText "";
};